package edu.friday.controller;


import edu.friday.common.base.BaseController;
import edu.friday.common.result.TableDataInfo;
import edu.friday.model.Goods;
import edu.friday.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/goods")
public class GoodsController extends BaseController {
    @Autowired
    GoodsService goodsService;

    @GetMapping("/list")
    public TableDataInfo list(Goods goods, Pageable page) {
        int pageNum = page.getPageNumber() -1;
        pageNum = pageNum < 0 ? 0 : pageNum;
        page = PageRequest.of(pageNum, page.getPageSize());
        return goodsService.selectGoodsList(goods, page);
    }

}